package com.cloudwalk.libscan.utils;

import android.content.Context;

/**
 * @ProjectName: ScanDemo_with_lib
 * @ClassName: TimerUtils
 * @Description: java类作用描述
 * @Author: 邹毅
 * @CreateDate: 2019/4/11 11:30
 * @UpdateUser: 更新者
 * @UpdateDate: 2019/4/11 11:30
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class TimerUtils {

    /**
     * 语音实例
     */
    public volatile static TimerUtils instance = null;
    /**
     * 上下文
     */
    static Context mContext;
    /**
     * 当前时间
     */
    private long currentTime = System.currentTimeMillis();

    /**
     * 私有化构造方法
     */
    private TimerUtils() {

    }

    /**
     * 以单例模式获取实例
     * @return
     */
    public static TimerUtils getInstance() {
        if (instance == null) {
            synchronized (TimerUtils.class) {
                if (instance == null) {
                    instance = new TimerUtils();
                }
            }
        }
        return instance;
    }

    /**
     * 时间间隔判断
     * @param timerGap
     * @return
     */
    public boolean isTimeUp(int timerGap) {
        if (System.currentTimeMillis() - currentTime < timerGap) {
            return false;
        }else {
            currentTime = System.currentTimeMillis();
            return true;
        }
    }

}
